using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using IFWiki.Models;
namespace IFWiki.Controllers
{
    public class HistoryController : Controller
    {
        //
        // GET: /History/

        public ActionResult Index(string name, string type)
        {
            type = type ?? "Article";
            return RedirectToAction("Index", type, new { name = name });
        }

        public ActionResult List(string innerType, string name)
        {

            Type innerTypeType;
            switch (innerType)
            {
                case "Game":      innerTypeType = typeof(Game);      break;
                case "GamePlace": innerTypeType = typeof(GamePlace); break;
                case "Article":   innerTypeType = typeof(Article);   break;
                default:
                    throw new Exception("Trying to find history of '" + name + "' with **unknown** type: '" + innerType + "'");
            }

            var history = new History(innerTypeType, name);

            return View(history);
        }

        public ActionResult ViewSource(string name, string type)
        {
            type = type ?? "Article";
            return RedirectToAction("ViewSource", type, new { name = name });
            
        }

    }
}
